/// @file Clock.h
#pragma once

#include <QLabel>
#include <QTimer>

namespace qtangram {
    /**
      @class Clock
      @brief Displays time in format HH:MM:SS, auto-updates every second
    */
    class Clock : public QLabel {
	Q_OBJECT
    public:
	typedef unsigned int second; ///< measurment unit type (1 second)
	Clock(QWidget* parent = 0, Qt::WindowFlags f = 0, const QString& text = QString("00:00:00")); ///< @brief default constructor
	void start(); ///< @brief Zeroes elapsed time, starts timer.
	void pause(); ///< @brief Starts or stops timer depending on its state.
	void stop(); ///< @brief Stops timer
	second getSeconds() const { return secs; } ///< @return elapsed time in measurment unit
	QString getTime(); /// < @return elapsed time in HH:MM:SS format
	void reset() { stop(); secs = 0; setText(getTime()); } /// @brief Stops timer, zeroes elapsed time and update displayed time.
    private slots:
	void ref();
    private:
	second secs;
	QTimer* timer;
    };
}
